//
//  AppController.h
//  PicUploader
//
//  Created by Chen Zhang on 8/13/08.
//  Copyright 2008 overboming. All rights reserved.

#import <Cocoa/Cocoa.h>

@class ZCScraping;
@class PreferenceController;
@class PUTableView;
@class WLQuickLookBridge;
@class PUPicture;
@class PUBoard;

@interface AppController : NSObject {
    NSMutableArray *pictures;
    IBOutlet PUTableView *tableView;
    IBOutlet NSArrayController *picturesController;
    IBOutlet NSWindow *loginSheet;
    IBOutlet NSTextField *statusBar;
    IBOutlet NSProgressIndicator *progress;
    IBOutlet NSWindow *aboutMePanel;
	IBOutlet NSButton *qlButton;
    
    //login window
    IBOutlet NSTextField *userNameText;
    IBOutlet NSSecureTextField *passwordText;
    IBOutlet NSComboBox *boardNameBox;
    IBOutlet NSMenuItem *switchUserMenu;
    
    //post tab
    IBOutlet NSTabView *tabView;
    IBOutlet NSButton *postArticleButton;
    IBOutlet NSTextView *uploadContent;
    IBOutlet NSTextField *titleField;
    IBOutlet NSComboBox *sigComboBox;
    IBOutlet NSComboBox *boardNameBoxForPost;
    
    
    //sugguestion window
    IBOutlet NSWindow *suggestSheet;
    IBOutlet NSTextView *sugguestionTextView;
    IBOutlet NSComboBox *sigSComboBox;
    IBOutlet NSButton *sendSuggestButton;
    IBOutlet NSProgressIndicator *postProgress;
    
    IBOutlet NSMenuItem *switchMenu;
    
    //Status Text
    NSString *statusTextBar;    
    ZCScraping *scrapeManager;
    
    //upload string
    NSString *uploadString;
    
    //Preference controller
    PreferenceController *preferenceController;
    int uploadCounter;
    int validPicNum; //how many pictures are available 
    int nextComePicNum;
    int currentDoneNum;
    int maxThreadNum;
    
    //multithreading lock
    NSLock *threadLock;
    
    NSFont *smallFont;
    NSString *currentBoardName;
    
    NSMutableArray *listOfBoardName;
    NSString *imageQuality;
    NSString *imageSize;
    
    int whetherStarted;
    
    NSString *sCacheDir;
    
    //Dock tile
    NSDockTile*	dockTile;
    
}

- (IBAction)showOpenPanel:(id)sender;
- (IBAction)showLoginSheet:(id)sender;
- (IBAction)endLoginSheet:(id)sender;
- (IBAction)dismissLoginSheet:(id)sender;
- (IBAction)showSuggestionPanel:(id)sender;
- (IBAction)endSuggestionSheet:(id)sender;
- (IBAction)showAboutMePanel:(id)sender;
- (IBAction)cancelAndQuit:(id)sender;
- (IBAction)uploadAll:(id)sender;
- (IBAction)showPreferencePanel:(id)sender;
- (void) uploadCompleteForOneThread:(NSString *)filename Path:(NSString *)filepath;
- (PUPicture *) findPictureByFilePath:(NSString *)filepath;
- (void) acceptDragOperation:(NSString *)path;
- (void) acceptDragOperationForDraggedImage:(NSData *)data;
- (BOOL) acceptFileName:(NSString *)filename;
- (IBAction)previewSelectedItems:(id)sender;
- (void) UploadThreadDelegate:(id)path;
- (IBAction)postMyArticle:(id)sender;
- (IBAction)postMySuggestion:(id)sender;
- (void) firstLoginThread:(id)object;
- (int) countValidPicture;
- (void)fireupNewThread:(id)object;
/*handle notification*/
- (void)handleFavBoardChange:(NSNotification *)note;
- (void)handleThreadNumChange:(NSNotification *)note;
- (void)handleBoardListChange:(NSNotification *)note;
- (void)handleImageQualityChange:(NSNotification *)note;
- (void)handleImageSizeChange:(NSNotification *)note;
- (IBAction) convertToSmallerSize:(id)sender;
- (IBAction) rotateTo90Degrees:(id)sender;
- (NSString *)handleLargeFile:(NSString *)filePath ImageQuality:(NSString *)str;
- (NSString *)rotatePicture:(NSString *)filePath;
//- (NSString *)handleLargeFileManually:(NSString *)filePath;
- (NSString *)handleLargeFile:(NSString *)filePath ImageQuality:(NSString *)str toSize:(NSString *)sizestr;
- (void)endCurrentTask;
- (int) checkFileSize:(NSString *)filePath;

- (IBAction)removeFromArrayController:(id)sender;

@property (readwrite,copy) NSString* statusTextBar;
@property (readwrite,copy) NSString* uploadString;
@property (readwrite,copy) ZCScraping* scrapeManager;
@property (readonly,copy)   NSComboBox *boardNameBox;
@property (readonly,copy) NSProgressIndicator *progress;
@property (readonly,copy)  NSTextField *statusBar;
@property (readwrite) int nextComePicNum;
@property (readonly) int maxThreadNum;
@property (readonly) int currentDoneNum;
@property (readwrite,copy) NSString *currentBoardName;
@end
